package com.le.tester.onjava8.l1_10_2;

import java.util.Random;

/**
 * createTime：2022/10/27 10:34
 * description：
 */
public enum Input {

    NICKEL(5), DIME(10),
    ABORT_TRANSACTION {
        public int amount() {
            throw new RuntimeException("ABORT.amount()");
        }
    },
    STOP {
        public int amount() {
            throw new RuntimeException("SHUT_AMOUNT()");
        }
    };
    int value;

    Input(int value) {
        this.value = value;
    }

    Input() {
    }

    int amount() {
        return value;
    }

    static Random random = new Random(47);

    public static Input randomSelection() {
        return values()[random.nextInt(values().length - 1)];
    }
}
